<template>
    <div class="wrapper tocash">
        <mt-header :fixed="false" title="提现" mtClass="no-bg" />
        <div class="blank-9"></div>
        <div class="list">
            <div style="padding:10px 0;">验证账号</div>
            <countdown @sendValueToParent="getValueFromChild" :mobile="$route.query.mobile"></countdown>
        </div>
        <div class="blank-9"></div>
        <div class="list">
            <inputPayPwd title="支付密码" @sendValueToParent="getPayPwdFromChild"></inputPayPwd>
        </div>
        <div class="missPsd-btn" @click="toEditPayPwd">忘记密码</div>
        <div class="blank-9"></div>
        <div class="default-btn">
            <mt-button type="primary" size="large" :disabled="(inputValueCode && realInput.length==6)?false:true" @click.native="toCash">确定</mt-button>
        </div>
    </div>
</template>

<script>
import mtHeader from "@/components/Header"
import { Toast } from 'mint-ui';
import countdown from "@/components/Countdown"
import inputPayPwd from "@/components/InputPayPwd"
import { PostExtract } from '@/api/api'
export default {
    data() {
        return {
            realInput:'',
            inputValueCode:''
        }
    },
    components:{
        mtHeader,
        countdown,
        inputPayPwd
    },
    methods: {
        getPayPwdFromChild(value){
            this.realInput = value;
        },
        getValueFromChild(value){
            this.inputValueCode = value;
        },
        toCash(){
            PostExtract({
                extractAddress:this.$route.query.extractAddress,
                extractCount:this.$route.query.extractCount,
                validationCode:this.inputValueCode,
                payPassword:this.realInput
            }).then(res => {
                if( res.code == 200 ){
                    //提现成功
                    Toast({
                        message: "提现成功"
                    });
                    this.$router.push('/account/wallet/cashres')
                }else{
                    Toast({
                        message: res.msg,
                        iconClass: 'icon iconfont icon-dingdanzhuangtaishibai'
                    })
                }
            })
        },
        toEditPayPwd(){
            this.$router.push({
                path : '/account/setting/editPayPwd/findPayPwd',
                query:{ 
                    mobile:this.$route.query.mobile
                }
            })
        }
    }
}
</script>

<style lang="stylus" scoped>
.wrapper{
    .missPsd-btn{
        display:block;
        text-align right;
        color: #5F88FF;
        font-size: 12px;
        margin-bottom: 15px;
        margin-right: 37px;
    }
}  
</style>